extends StateBase
class_name StateAttackEnemy01


var enemy01:Enemy01
var attack = false


func enterState(ownerNode):
	pass
	
	
func exitState(ownerNode):
	pass
	
	
func process(delta, ownerNode):
	pass
	
	
func physicsProcess(delta, ownerNode):
	if not enemy01:
		enemy01 =  ownerNode as Enemy01
	
	if enemy01.animations.current_animation != "Idle":
		enemy01.animations.play("Idle")
		
	if not attack:
		attack = true
		enemy01.weaponAnimations.play("ClubAttack")
		$AttackTimer.start()
		
	if attack and $AttackTimer.time_left <= 0:
		onAttackFinished(ownerNode)
		
	
func onAttackFinished(ownerNode):
	stateMachine.changeState("StateIdle", ownerNode)
	attack = false

